package cn.itcast.Rainbow_self_mention.Activity;

import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;

import cn.itcast.Rainbow_self_mention.R;
import cn.itcast.Rainbow_self_mention.Tools.QRCodeMaker;


public class QRCodeActivity extends Activity {
    String username = null;
    TextView name;
    TextView info;
    TextView title;
    ImageView code;
    ImageView back;

    protected void onCreate(@Nullable Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.qrcode);
    }
    @Override
    protected void onResume() {
        super.onResume();
        username = getIntent().getStringExtra("username");
        init();
        initdate();
    }
    public void init() {
        name = findViewById(R.id.name);
        info = findViewById(R.id.info);
        code = findViewById(R.id.code);
        back = findViewById(R.id.history_back);
        title=findViewById(R.id.title);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
    public void finish(){
        super.finish();
        overridePendingTransition(0, 0);
    }
    public void initdate() {
        name.setText(username);
        info.setText(getIntent().getStringExtra("code"));
        title.setText(getIntent().getStringExtra("stance"));
        Bitmap codeBitmap = QRCodeMaker.createQRCode(getIntent().getStringExtra("code"), 500, 500);
        code.setImageBitmap(codeBitmap);
    }
}
